package csc.com.service;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;


public class WriteFile {
	public void writeData(String data1, String data2) {
		StringBuilder content = new StringBuilder();
		FileOutputStream fop = null;
		File file;
		try {
			// All information will be save in customer.txt file.
			file = new File("d:/logging.txt");
			fop = new FileOutputStream(file,true);
			// if file doesnt exists, then create it
			if (!file.exists()) {
				file.createNewFile();
			}
			content.append(data1);
			content.append(System.getProperty("line.separator"));
			content.append(data2);
			content.append(System.getProperty("line.separator"));
			// get the content in bytes
			byte[] contentInBytes = content.toString().getBytes();
			fop.write(contentInBytes);
			fop.flush();
			fop.close();
		} catch (IOException e) {
			e.printStackTrace();
		} finally {
			try {
				if (fop != null) {
					fop.close();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}
